package com.jk.smartelderlycare.controller;

import com.jk.smartelderlycare.dto.SysTution;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.pojo.ResponseResult;
import com.jk.smartelderlycare.service.SysTuionServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysTutionController
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/13 19:28
 */

@Api(tags = "机构管理模块")
@RestController
@CrossOrigin
@RequestMapping(value = "sysTution")
public class SysTutionController {
    
    @Autowired
    private SysTuionServiceFeign sysTuionServiceFeign;
    
    /** 
     * @description: 机构列表后端分页查询
     * @param: [sysTution, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult<com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysTution>>
     * @author hhk
     * @date: 2024/11/13 19:36
     */ 
    @ApiOperation(value = "机构列表后端分页查询",httpMethod = "POST",notes = "机构列表后端分页查询")
    @PostMapping(value = "findSysTutionPagimationList")
    public ResponseResult<PagedResponse<SysTution>>findSysTutionPagimationList(@RequestBody SysTution sysTution, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize){
      return new ResponseResult<>(200,"查询成功",sysTuionServiceFeign.findSysTutionPagimationList(sysTution,pageNum,pageSize));
    }
    /** 
     * @description: 机构新增
     * @param: [sysTution]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/13 20:29
     */ 
    @ApiOperation(value = "机构新增",httpMethod = "POST",notes = "机构新增")
    @PostMapping(value = "addSysTution")
    private ResponseResult addSysTution(@RequestBody SysTution sysTution) {
        try {
            sysTuionServiceFeign.addSysTution(sysTution);
            return new ResponseResult(200,"新增成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"新增失败");
        }
    }
    /** 
     * @description: 根据id机构删除
     * @param: [tutionId]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/13 20:32
     */ 
    @ApiOperation(value = "根据id机构删除",httpMethod = "DELETE",notes = "机构删除")
    @DeleteMapping(value = "deleteSysTutionByTutionId")
    public ResponseResult deleteSysTutionByTutionId(@RequestParam(value = "tutionId") Long tutionId){
        try {
            sysTuionServiceFeign.deleteSysTutionByTutionId(tutionId);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"删除失败");
        }
    }
    /** 
     * @description: 根据id回显机构
     * @param: [tutionId]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/13 20:32
     */ 
    @ApiOperation(value = "根据id回显机构",httpMethod = "GET",notes = "回显机构")
    @GetMapping(value = "findSysTutionByTutionId")
    private ResponseResult findSysTutionByTutionId(@RequestParam(value = "tutionId") Long tutionId){
        return new ResponseResult(200,"查询成功",sysTuionServiceFeign.findSysTutionByTutionId(tutionId));
    }
    /** 
     * @description: 修改机构
     * @param: [sysTution]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/13 20:33
     */ 
    @ApiOperation(value = "修改机构",httpMethod = "PUT",notes = "修改机构")
    @PutMapping(value = "updataSysTution")
    public ResponseResult updataSysTution(@RequestBody SysTution sysTution){
        try {
            sysTuionServiceFeign.updataSysTution(sysTution);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");
        }
    }
    /** 
     * @description: 标签动态下拉列表
     * @param: []
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/13 20:35
     */ 
    @ApiOperation(value = "标签动态下拉列表",httpMethod = "GET",notes = "标签动态下拉列表")
    @GetMapping(value ="findSysLabelList")
    private ResponseResult findSysLabelList(){
        return new ResponseResult(200,"查询成功",sysTuionServiceFeign.findSysLabelList());
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}
